package com.itheima.tlias.interceptor;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

/**
 * 测试拦截器
 *
 * @Author mr.luo
 * @Date 16 4月 2025 10:14
 */
@Slf4j
@Component
//@Order(1)
//public class Demo1Interceptor implements HandlerInterceptor, Ordered {
public class Demo1Interceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
       log.info("[Demo1Interceptor]目标资源拦截器，目标资源方法执行前的逻辑");
       return true;
    }

    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        log.info("[Demo1Interceptor]目标资源拦截器，目标资源方法执行后的逻辑");
    }

    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        log.info("[Demo1Interceptor]目标资源拦截器，视图渲染完成后的逻辑");
    }

//    @Override
//    public int getOrder() {
//        return 2;
//    }
}
